home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqtools / memory.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-18  |  10.0 KB  |  292 lines

  1. #ifndef    MEMORY_H
  2. #define    MEMORY_H
  3. /*
  4.  * ============================================================================
  5.  * structures
  6.  * ============================================================================
  7.  */
  8.  
  9. /* key / value pair sizes */
  10. #define    MAX_KEY            32
  11. #define    MAX_VALUE        1024
  12.  
  13. /* QuakeI */
  14. #define    MAX_MAP_MODELS        256
  15. #define    MAX_MAP_ENTSTRING    65536
  16. #define    MAX_MAP_PLANES        8192                /*    8192 */
  17. #define    MAX_MAP_NODES        9216                /*   32767        // because negative shorts are contents */
  18. #define    MAX_MAP_CLIPNODES    24576                /*   32767        // */
  19. #define    MAX_MAP_LEAFS        6144                /*   32767        // */
  20. #define    MAX_MAP_VERTS        23552                /*   65535 */
  21. #define    MAX_MAP_FACES        18432                /*   65535 */
  22. #define    MAX_MAP_MARKSURFACES    23552                /*   65535 */
  23. #define    MAX_MAP_TEXINFO        1024                /*    4096 */
  24. #define    MAX_MAP_EDGES        43008                /*  256000 */
  25. #define    MAX_MAP_SURFEDGES    82944                /*  512000 */
  26. #define    MAX_MAP_TEXTURES    0x200000
  27. #define    MAX_MAP_LIGHTING    614400                /*0x100000 */
  28. #define    MAX_MAP_VISIBILITY    163840                /*0x100000 */
  29. /* QuakeII */
  30. #define    MAX_MAP_AREAS        32                /*256 */
  31. #define    MAX_MAP_AREAPORTALS    256                /*1024 */
  32. #define    MAX_MAP_BRUSHES        4096                /*65536 */
  33. #define    MAX_MAP_BRUSHSIDES    4096                /*65536 */
  34. #define    MAX_MAP_LEAFFACES    MAX_MAP_MARKSURFACES
  35. #define    MAX_MAP_LEAFBRUSHES    4096                /*65536 */
  36.  
  37. /* QuakeI */
  38. #define CLUSTER_MODELS        32
  39. #define CLUSTER_ENTSTRING    8192
  40. #define CLUSTER_PLANES        512                /*1024 */
  41. #define CLUSTER_NODES        1024                /*4096 */
  42. #define CLUSTER_CLIPNODES    1024                /*4096 */
  43. #define CLUSTER_LEAFS        1024                /*2048 */
  44. #define CLUSTER_VERTS        2048                /*8192 */
  45. #define CLUSTER_FACES        1024                /*4096 */
  46. #define CLUSTER_MARKSURFACES    512                /*892 */
  47. #define CLUSTER_TEXINFO        512
  48. #define CLUSTER_EDGES        4096                /*16384 */
  49. #define CLUSTER_SURFEDGES    4096                /*16384 */
  50. #define CLUSTER_TEXTURES    65536
  51. #define CLUSTER_LIGHTING    65536
  52. #define CLUSTER_VISIBILITY    32768
  53. /* QuakeII */
  54. #define    CLUSTER_AREAS        8
  55. #define    CLUSTER_AREAPORTALS    64
  56. #define    CLUSTER_BRUSHES        1024
  57. #define    CLUSTER_BRUSHSIDES    1024
  58. #define    CLUSTER_LEAFFACES    CLUSTER_MARKSURFACES
  59. #define    CLUSTER_LEAFBRUSHES    1024
  60.  
  61. /* QuakeI */
  62. #define    LUMP_ENTITIES        (1<<0)
  63. #define    LUMP_PLANES        (1<<1)
  64. #define    LUMP_TEXTURES        (1<<2)
  65. #define    LUMP_VERTEXES        (1<<3)
  66. #define    LUMP_VISIBILITY        (1<<4)
  67. #define    LUMP_NODES        (1<<5)
  68. #define    LUMP_TEXINFO        (1<<6)
  69. #define    LUMP_FACES        (1<<7)
  70. #define    LUMP_LIGHTING        (1<<8)
  71. #define    LUMP_CLIPNODES        (1<<9)
  72. #define    LUMP_LEAFS        (1<<10)
  73. #define    LUMP_MARKSURFACES    (1<<11)
  74. #define    LUMP_EDGES        (1<<12)
  75. #define    LUMP_SURFEDGES        (1<<13)
  76. #define    LUMP_MODELS        (1<<14)
  77. /* QuakeII */
  78. #define    LUMP_AREAS        (1<<15)
  79. #define    LUMP_AREAPORTALS    (1<<16)
  80. #define    LUMP_BRUSHES        (1<<17)
  81. #define    LUMP_BRUSHSIDES        (1<<18)
  82. #define    LUMP_LEAFFACES        LUMP_MARKSURFACES
  83. #define    LUMP_LEAFBRUSHES    (1<<19)
  84. #define    LUMP_POPS        (1<<20)
  85.  
  86. #define    BSP_QUAKE1_LUMPS    (((1<<15)-1) & (~LUMP_TEXTURES) & (~LUMP_LIGHTING) & (~LUMP_VISIBILITY))
  87.  
  88. #define    ALL_QUAKE1_LUMPS    ((1<<15)-1)
  89. #define    ALL_QUAKE2_LUMPS    ((1<<21)-1 & (~LUMP_TEXTURES) & (~LUMP_CLIPNODES))
  90.  
  91. /* ============================================================================ */
  92.  
  93. /* QuakeI */
  94. #define    MAX_MAP_ENTITIES    1024
  95. #define    MAX_MAP_TEXSTRINGS    MAX_MAP_TEXINFO
  96. #define    MAX_MAP_BRUSHFACES    MAX_MAP_FACES
  97. #define    MAX_MAP_BRUSHPLANES    MAX_MAP_PLANES
  98.  
  99. /* QuakeI */
  100. #define    CLUSTER_ENTITIES    128
  101. #define    CLUSTER_TEXSTRINGS    CLUSTER_TEXINFO
  102. #define    CLUSTER_BRUSHFACES    CLUSTER_FACES
  103. #define    CLUSTER_BRUSHPLANES    CLUSTER_PLANES
  104.  
  105. /* QuakeI */
  106. #define    MAP_ENTITIES        (1<<21)
  107. #define    MAP_TEXSTRINGS        (1<<22)
  108. #define    MAP_BRUSHPLANES        (1<<23)
  109. #define    MAP_BRUSHFACES              (1<<24)
  110.  
  111. #define    ALL_MAPS        (((1<<25)-1)-((1<<21)-1))
  112.  
  113. /* ============================================================================ */
  114.  
  115. /* QuakeI */
  116. #define    MAX_MAP_PORTALS        32768
  117.  
  118. /* QuakeI */
  119. #define    CLUSTER_PORTALS        4096
  120.  
  121. /* QuakeI */
  122. #define    VIS_PORTALS        (1<<25)
  123.  
  124. #define    ALL_VIS            (((1<<26)-1)-((1<<25)-1))
  125.  
  126. /* ============================================================================ */
  127.  
  128. #define MAX_MDL_TVERTS        2048
  129. #define MAX_MDL_FRAMES        256
  130. #define MAX_MDL_SKINS        100
  131.  
  132. /* QuakeI */
  133. #define CLUSTER_TVERTS        256
  134. #define CLUSTER_FRAMES        32
  135. #define CLUSTER_SKINS        10
  136.  
  137. /* QuakeI */
  138. #define MODEL_TVERTS        (1<<26)
  139. #define MODEL_FRAMES        (1<<27)
  140. #define MODEL_SKINS        (1<<28)
  141.  
  142. #define    ALL_MODEL        (((1<<29)-1)-((1<<26)-1))
  143.  
  144. /* ============================================================================ */
  145.  
  146. #define MAX_TRIANGLES        2048
  147.  
  148. #define CLUSTER_TRIANGLES    512
  149.  
  150. #define TRIANGLES        (1<<29)
  151.  
  152. #define    ALL_TRIANGLES        (((1<<30)-1)-((1<<29)-1))
  153.  
  154. /* ============================================================================ */
  155.  
  156. struct memory {
  157.   int availHeaders;
  158.   unsigned char mapOptions, bspOptions, litOptions,
  159.         visOptions, mdlOptions, dspOptions;
  160.   unsigned char mapVersion, bspVersion, litVersion,
  161.         visVersion, mdlVersion, dspVersion;
  162.  
  163.   union {
  164.     struct {
  165.       /* all bsps */
  166.       int entdatasize,        max_entdatasize;    char *dentdata;
  167.       int numplanes,        max_numplanes;        struct dplane_t *dplanes;
  168.       int numvertexes,        max_numvertexes;    struct dvertex_t *dvertexes;
  169.       int visdatasize,        max_visdatasize;    unsigned char *dvisdata;
  170.       int numnodes,        max_numnodes;        struct dnode_t *dnodes;
  171.       int numtexinfo,        max_numtexinfo;        struct texinfo *texinfo;
  172.       int numfaces,        max_numfaces;        struct dface_t *dfaces;
  173.       int lightdatasize,    max_lightdatasize;    unsigned char *dlightdata;
  174.       int numleafs,        max_numleafs;        struct dleaf_t *dleafs;
  175.       int nummarksurfaces,    max_nummarksurfaces;    unsigned short int *dmarksurfaces;
  176.       int numedges,        max_numedges;        struct dedge_t *dedges;
  177.       int numsurfedges,        max_numsurfedges;    int *dsurfedges;
  178.       int nummodels,        max_nummodels;        struct dmodel_t *dmodels;
  179.  
  180.       /* all models */
  181.     } all;
  182.     struct {
  183.       /* standard bsp 29 */
  184.       int entdatasize,        max_entdatasize;    char *dentdata;
  185.       int numplanes,        max_numplanes;        struct dplane_t *dplanes;
  186.       int numvertexes,        max_numvertexes;    struct dvertex_t *dvertexes;
  187.       int visdatasize,        max_visdatasize;    unsigned char *dvisdata;
  188.       int numnodes,        max_numnodes;        struct dnode_t *dnodes;
  189.       int numtexinfo,        max_numtexinfo;        struct texinfo *texinfo;
  190.       int numfaces,        max_numfaces;        struct dface_t *dfaces;
  191.       int lightdatasize,    max_lightdatasize;    unsigned char *dlightdata;
  192.       int numleafs,        max_numleafs;        struct dleaf_t *dleafs;
  193.       int nummarksurfaces,    max_nummarksurfaces;    unsigned short int *dmarksurfaces;
  194.       int numedges,        max_numedges;        struct dedge_t *dedges;
  195.       int numsurfedges,        max_numsurfedges;    int *dsurfedges;
  196.       int nummodels,        max_nummodels;        struct dmodel_t *dmodels;
  197.  
  198.       int texdatasize,        max_texdatasize;    unsigned char *dtexdata;
  199.       int numclipnodes,        max_numclipnodes;    struct dclipnode_t *dclipnodes;
  200.  
  201.       /* standard model 6 */
  202.     } quake1;
  203.     struct {
  204.       /* standard bsp 38 */
  205.       int entdatasize,        max_entdatasize;    char *dentdata;
  206.       int numplanes,        max_numplanes;        struct dplane_t *dplanes;
  207.       int numvertexes,        max_numvertexes;    struct dvertex_t *dvertexes;
  208.       int numclusters,        max_numclusters;    struct dvis2_t *clusters;
  209.       int numnodes,        max_numnodes;        struct dnode2_t *dnodes;
  210.       int numtexinfo,        max_numtexinfo;        struct texinfo2 *texinfo;
  211.       int numfaces,        max_numfaces;        struct dface_t *dfaces;
  212.       int lightdatasize,    max_lightdatasize;    unsigned char *dlightdata;
  213.       int numleafs,        max_numleafs;        struct dleaf2_t *dleafs;
  214.       int numleaffaces,        max_numleaffaces;    unsigned short int *dleaffaces;
  215.       int numedges,        max_numedges;        struct dedge_t *dedges;
  216.       int numsurfedges,        max_numsurfedges;    int *dsurfedges;
  217.       int nummodels,        max_nummodels;        struct dmodel2_t *dmodels;
  218.  
  219.       int numleafbrushes,    max_numleafbrushes;    unsigned short int *dleafbrushes;
  220.       int numbrushes,        max_numbrushes;        struct dbrush2_t *dbrushes;
  221.       int numbrushsides,    max_numbrushsides;    struct dbrushside2_t *dbrushsides;
  222.       int numpops,        max_numpops;        unsigned char *dpops;
  223.       int numareas,        max_numareas;        struct darea2_t *dareas;
  224.       int numareaportals,    max_numareaportals;    struct dareaportal2_t *dareaportals;
  225.  
  226.       /* standard model 8 */
  227.     } quake2;
  228.   } shared;
  229.  
  230.   /* extras for maps */
  231.   int nummapentities,        max_nummapentities;    struct entity *mapentities;
  232.   int nummaptexstrings,        max_nummaptexstrings;    char **maptexstrings;
  233.   int numbrushfaces,        max_numbrushfaces;    struct mface *brushfaces;
  234.   int numbrushplanes,        max_numbrushplanes;    struct plane *brushplanes;
  235.  
  236.   /* extras for triangles */
  237.   int numtriangles,        max_numtriangles;    struct triangle *triangles;
  238.                             int *degenerate;
  239.  
  240.   /* extras for models */
  241.   int numverts,            max_numverts;        struct trivert **verts;
  242.                             struct trivertex *tarray;
  243.                             struct stvert *stverts;
  244.                             vec3_t *baseverts;
  245.                             struct vertexnormals *vnorms;
  246.   int numframes,        max_numframes;        struct aliaspackage *frames;
  247.   int numskins,            max_numskins;        struct aliasskinpackage *skins;
  248.  
  249.   /* extras */
  250.                             struct visfacet **edgefaces[2];
  251.  
  252.   /* extras for light */
  253.  
  254.   /* extras for vis */
  255.   int numportals,        max_numportals;        unsigned char *portalsee;
  256.  
  257.   /* configureable maxima */
  258. #ifndef    CUSTOM_MAXIMA
  259. # define    MAXEDGES        32            /* 64     32 */
  260. # define    MAXPOINTS        28            /* 56     28                         dont let a base face get past this */
  261.   /* because it can be split more later */
  262. # define    MAX_EDGES_IN_REGION    32
  263. # define    MAX_PORTALS_ON_LEAF    128
  264. #else
  265. # define    DEFEDGES        32
  266. # define    DEFPOINTS        28
  267. # define    DEF_EDGES_IN_REGION    32
  268. # define    DEF_PORTALS_ON_LEAF    128
  269. # define    MAXEDGES        bspMem->maxedges
  270. # define    MAXPOINTS        bspMem->maxpoints
  271. # define    MAX_EDGES_IN_REGION    bspMem->maxedges_in_region
  272. # define    MAX_PORTALS_ON_LEAF    bspMem->maxportals_on_leaf
  273.   int maxpoints;
  274.   int maxedges;
  275.   int maxedges_in_region;
  276.   int maxportals_on_leaf;
  277. #endif
  278. } __packed;
  279.  
  280. /*
  281.  * ============================================================================
  282.  * prototypes
  283.  * ============================================================================
  284.  */
  285.  
  286. void PrintClusters(__memBase, int printType, bool toDisk);
  287. void AllocClusters(__memBase, int allocType);
  288. void ExpandClusters(__memBase, int allocType);
  289. void FreeClusters(__memBase, int freeType);
  290.  
  291. #endif
  292.